home *** CD-ROM | disk | FTP | other *** search
/ PC World 2004 February / PCWorld_2004-02_cd.bin / software / vyzkuste / inno / isetup-4.0.10.exe / {app} / Examples / CodeClasses.iss next >
Text File  |  2003-10-28  |  10KB  |  268 lines

  1. ; -- CodeClasses.iss --
  2. ;
  3. ; This script shows how to use the WizardForm object and the various VCL classes.
  4.  
  5. [Setup]
  6. AppName=My Program
  7. AppVerName=My Program version 1.5
  8. CreateAppDir=no
  9. DisableProgramGroupPage=yes
  10. DefaultGroupName=My Program
  11. UninstallDisplayIcon={app}\MyProg.exe
  12.  
  13. [Code]
  14. procedure AboutButtonOnClick(Sender: TObject);
  15. begin
  16.   MsgBox('This demo shows some features of the WizardForm object and the various VCL classes.', mbInformation, mb_Ok);
  17. end;
  18.  
  19. procedure InitializeWizard();
  20. var
  21.   AboutButton, CancelButton: TButton;
  22. begin
  23.   CancelButton := WizardForm.CancelButton;
  24.  
  25.   AboutButton := TButton.Create(WizardForm);
  26.   AboutButton.Left := WizardForm.ClientWidth - CancelButton.Left - CancelButton.Width;
  27.   AboutButton.Top := CancelButton.Top;
  28.   AboutButton.Width := CancelButton.Width;
  29.   AboutButton.Height := CancelButton.Height;
  30.   AboutButton.Caption := '&About...';
  31.   AboutButton.OnClick := @AboutButtonOnClick;
  32.   AboutButton.Parent := WizardForm;
  33. end;
  34.  
  35. procedure ButtonOnClick(Sender: TObject);
  36. begin
  37.   MsgBox('You clicked the button!', mbInformation, mb_Ok);
  38. end;
  39.  
  40. procedure FormButtonOnClick(Sender: TObject);
  41. var
  42.   Form: TForm;
  43.   Button: TButton;
  44. begin
  45.   Form := TForm.Create(WizardForm);
  46.   Form.Width := 256;
  47.   Form.Height := 256;
  48.   Form.Caption := 'TForm';
  49.   Form.Position := poScreenCenter;
  50.  
  51.   Button := TButton.Create(Form);
  52.   Button.Parent := Form;
  53.   Button.Left := 8;
  54.   Button.Top := Form.ClientHeight - Button.Height - 10;
  55.   Button.Caption := 'Close';
  56.   Button.ModalResult := mrOk;
  57.  
  58.   Form.ActiveControl := Button;
  59.  
  60.   Form.ShowModal();
  61.   Form.Release();
  62. end;
  63.  
  64. function ScriptDlgPages(CurPage: Integer; BackClicked: Boolean): Boolean;
  65. var
  66.   CurSubPage: Integer;
  67.   Next: Boolean;
  68.   Button, FormButton: TButton;
  69.   CheckBox: TCheckBox;
  70.   Edit: TEdit;
  71.   Memo: TMemo;
  72.   Lbl, ProgressBarLabel: TLabel;
  73.   ComboBox: TComboBox;
  74.   ListBox: TListBox;
  75.   StaticText: TNewStaticText;
  76.   ProgressBar: TNewProgressBar;
  77.   CheckListBox, CheckListBox2: TNewCheckListBox;
  78.   DirectoryListBox: TNewDirectoryListBox;
  79.   DriveComboBox: TNewDriveComboBox;
  80.   RichEditViewer: TRichEditViewer;
  81. begin
  82.   if (not BackClicked and (CurPage = wpWelcome)) or (BackClicked and (CurPage = wpReady)) then begin
  83.     if not BackClicked then
  84.       CurSubPage := 0
  85.     else
  86.       CurSubPage := 4;
  87.     ScriptDlgPageOpen();
  88.     ScriptDlgPageSetCaption('Custom wizard page controls');
  89.     ScriptDlgPageSetSubCaption2('');
  90.     while (CurSubPage >= 0) and (CurSubPage <= 4) and not Terminated do begin
  91.       case CurSubPage of
  92.         0:
  93.           begin
  94.             ScriptDlgPageSetSubCaption1('TButton and others');
  95.             ScriptDlgPageClearCustom();
  96.  
  97.             Button := TButton.Create(WizardForm.ScriptDlgPanel);
  98.             Button.Caption := 'TButton';
  99.             Button.OnClick := @ButtonOnClick;
  100.             Button.Parent := WizardForm.ScriptDlgPanel;
  101.  
  102.             CheckBox := TCheckBox.Create(WizardForm.ScriptDlgPanel);
  103.             CheckBox.Top := Button.Top + Button.Height + 8;
  104.             CheckBox.Caption := 'TCheckBox';
  105.             CheckBox.Checked := True;
  106.             CheckBox.Width := WizardForm.ScriptDlgPanel.Width;
  107.             CheckBox.Parent := WizardForm.ScriptDlgPanel;
  108.  
  109.             Edit := TEdit.Create(WizardForm.ScriptDlgPanel);
  110.             Edit.Top := CheckBox.Top + CheckBox.Height + 8;
  111.             Edit.Text := 'TEdit';
  112.             Edit.Width := WizardForm.ScriptDlgPanel.Width;
  113.             Edit.Parent := WizardForm.ScriptDlgPanel;
  114.  
  115.             Memo := TMemo.Create(WizardForm.ScriptDlgPanel);
  116.             Memo.Top := Edit.Top + Edit.Height + 8;
  117.             Memo.ScrollBars := ssVertical;
  118.             Memo.Width := WizardForm.ScriptDlgPanel.Width;
  119.             Memo.Parent := WizardForm.ScriptDlgPanel;
  120.             Memo.Lines.Text := 'TMemo';
  121.  
  122.             Lbl := TLabel.Create(WizardForm.ScriptDlgPanel);
  123.             Lbl.Top := Memo.Top + Memo.Height + 8;
  124.             Lbl.Caption := 'TLabel';
  125.             Lbl.AutoSize := True;
  126.             Lbl.Parent := WizardForm.ScriptDlgPanel;
  127.  
  128.             FormButton := TButton.Create(WizardForm.ScriptDlgPanel);
  129.             FormButton.Top := Lbl.Top + Lbl.Height + 8;
  130.             FormButton.Caption := 'TForm';
  131.             FormButton.OnClick := @FormButtonOnClick;
  132.             FormButton.Parent := WizardForm.ScriptDlgPanel;
  133.  
  134.             Next := ScriptDlgPageProcessCustom();
  135.           end;
  136.         1:
  137.           begin
  138.             ScriptDlgPageSetSubCaption1('TComboBox and others');
  139.             ScriptDlgPageClearCustom();
  140.  
  141.             ComboBox := TComboBox.Create(WizardForm.ScriptDlgPanel);
  142.             ComboBox.Width := WizardForm.ScriptDlgPanel.Width;
  143.             ComboBox.Parent := WizardForm.ScriptDlgPanel;
  144.             ComboBox.Items.Add('TComboBox');
  145.             ComboBox.ItemIndex := 0;
  146.  
  147.             ListBox := TListBox.Create(WizardForm.ScriptDlgPanel);
  148.             ListBox.Top := ComboBox.Top + ComboBox.Height + 8;
  149.             ListBox.Width := WizardForm.ScriptDlgPanel.Width;
  150.             ListBox.Parent := WizardForm.ScriptDlgPanel;
  151.             ListBox.Items.Add('TListBox');
  152.             ListBox.ItemIndex := 0;
  153.  
  154.             StaticText := TNewStaticText.Create(WizardForm.ScriptDlgPanel);
  155.             StaticText.Top := ListBox.Top + ListBox.Height + 8;
  156.             StaticText.Caption := 'TNewStaticText';
  157.             StaticText.AutoSize := True;
  158.             StaticText.Parent := WizardForm.ScriptDlgPanel;
  159.  
  160.             ProgressBarLabel := TLabel.Create(WizardForm.ScriptDlgPanel);
  161.             ProgressBarLabel.Top := StaticText.Top + StaticText.Height + 8;
  162.             ProgressBarLabel.Caption := 'TNewProgressBar';
  163.             ProgressBarLabel.AutoSize := True;
  164.             ProgressBarLabel.Parent := WizardForm.ScriptDlgPanel;
  165.  
  166.             ProgressBar := TNewProgressBar.Create(WizardForm.ScriptDlgPanel);
  167.             ProgressBar.Left := ProgressBarLabel.Width + 8;
  168.             ProgressBar.Top := ProgressBarLabel.Top;
  169.             ProgressBar.Parent := WizardForm.ScriptDlgPanel;
  170.             ProgressBar.Position := 25;
  171.             ProgressBar.Width := WizardForm.ScriptDlgPanel.Width - ProgressBar.Left;
  172.             ProgressBar.Height := ProgressBarLabel.Height + 8;
  173.  
  174.             Next := ScriptDlgPageProcessCustom();
  175.           end;
  176.         2:
  177.           begin
  178.             ScriptDlgPageSetSubCaption1('TNewCheckListBox');
  179.             ScriptDlgPageClearCustom();
  180.  
  181.             CheckListBox := TNewCheckListBox.Create(WizardForm.ScriptDlgPanel);
  182.             CheckListBox.Flat := True;
  183.             CheckListBox.Width := WizardForm.ScriptDlgPanel.Width;
  184.             CheckListBox.Parent := WizardForm.ScriptDlgPanel;
  185.             CheckListBox.AddCheckBox('TNewCheckListBox', '', 0, True, True, False, nil);
  186.             CheckListBox.AddRadioButton('TNewCheckListBox', '', 1, 0, True, True, nil);
  187.             CheckListBox.AddRadioButton('TNewCheckListBox', '', 1, 0, False, True, nil);
  188.             CheckListBox.AddCheckBox('TNewCheckListBox', '', 0, True, True, False, nil);
  189.  
  190.             CheckListBox2 := TNewCheckListBox.Create(WizardForm.ScriptDlgPanel);
  191.             CheckListBox2.BorderStyle := bsNone;
  192.             CheckListBox2.Color := WizardForm.Color;
  193.             CheckListBox2.MinItemHeight := WizardForm.TasksList.MinItemHeight;
  194.             CheckListBox2.ShowLines := False;
  195.             CheckListBox2.WantTabs := True;
  196.             CheckListBox2.Flat := True;
  197.             CheckListBox2.Top := CheckListBox.Top + CheckListBox.Height + 8;
  198.             CheckListBox2.Width := WizardForm.ScriptDlgPanel.Width;
  199.             CheckListBox2.Parent := WizardForm.ScriptDlgPanel;
  200.             CheckListBox2.AddGroup('TNewCheckListBox', '', 0, nil);
  201.             CheckListBox2.AddRadioButton('TNewCheckListBox', '', 0, 0, True, True, nil);
  202.             CheckListBox2.AddRadioButton('TNewCheckListBox', '', 0, 0, False, True, nil);
  203.  
  204.             Next := ScriptDlgPageProcessCustom();
  205.           end;
  206.         3:
  207.           begin
  208.             ScriptDlgPageSetSubCaption1('TNewDriveComboBox and TNewDirectoryListBox');
  209.             ScriptDlgPageClearCustom();
  210.  
  211.             DriveComboBox := TNewDriveComboBox.Create(WizardForm.ScriptDlgPanel);
  212.             DriveComboBox.Width := WizardForm.ScriptDlgPanel.Width;
  213.             DriveComboBox.Parent := WizardForm.ScriptDlgPanel;
  214.  
  215.             DirectoryListBox := TNewDirectoryListBox.Create(WizardForm.ScriptDlgPanel);
  216.             DirectoryListBox.Top := DriveComboBox.Top + DriveComboBox.Height + 8;
  217.             DirectoryListBox.Width := WizardForm.ScriptDlgPanel.Width;
  218.             DirectoryListBox.Height := WizardForm.ScriptDlgPanel.Height - DirectoryListBox.Top;
  219.             DirectoryListBox.Parent := WizardForm.ScriptDlgPanel;
  220.             DirectoryListBox.Directory := ExpandConstant('{src}');
  221.  
  222.             DriveComboBox.DirList := DirectoryListBox;
  223.  
  224.             Next := ScriptDlgPageProcessCustom();
  225.           end;
  226.         4:
  227.           begin
  228.             ScriptDlgPageSetSubCaption1('TRichViewer');
  229.             ScriptDlgPageClearCustom();
  230.  
  231.             RichEditViewer := TRichEditViewer.Create(WizardForm.ScriptDlgPanel);
  232.             RichEditViewer.Parent := WizardForm.ScriptDlgPanel;
  233.             RichEditViewer.Scrollbars := ssVertical;
  234.             RichEditViewer.UseRichEdit := True;
  235.             RichEditViewer.RTFText := '{\rtf1\ansi\ansicpg1252\deff0\deflang1043{\fonttbl{\f0\fswiss\fcharset0 Arial;}}{\colortbl ;\red255\green0\blue0;\red0\green128\blue0;\red0\green0\blue128;}\viewkind4\uc1\pard\f0\fs20 T\cf1 Rich\cf2 Edit\cf3 Viewer\cf0\par}';
  236.             RichEditViewer.ReadOnly := True;
  237.             RichEditViewer.Width := WizardForm.ScriptDlgPanel.Width;
  238.             RichEditViewer.Height := WizardForm.ScriptDlgPanel.Height;
  239.  
  240.             Next := ScriptDlgPageProcessCustom();
  241.           end;
  242.       end;
  243.       if Next then
  244.         CurSubPage := CurSubPage + 1
  245.       else
  246.         CurSubPage := CurSubPage - 1;
  247.     end;
  248.     if not BackClicked then
  249.       Result := Next
  250.     else
  251.       Result := not Next;
  252.     ScriptDlgPageClose(not Result);
  253.   end else
  254.     Result := True;
  255. end;
  256.  
  257. function NextButtonClick(CurPage: Integer): Boolean;
  258. begin
  259.   Result := ScriptDlgPages(CurPage, False);
  260. end;
  261.  
  262. function BackButtonClick(CurPage: Integer): Boolean;
  263. begin
  264.   Result := ScriptDlgPages(CurPage, True);
  265. end;
  266.  
  267.  
  268.